package logic

import (
	"context"
	"goods-sys/models/mysql"

	"goods-sys/goodsrpc/goodsrpc"
	"goods-sys/goodsrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type FenPingLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewFenPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FenPingLogic {
	return &FenPingLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 查询
func (l *FenPingLogic) FenPing(in *goodsrpc.FenRequest) (*goodsrpc.FenResponse, error) {
	// todo: add your logic here and delete this line

	var data mysql.User
	if err := mysql.DB.Where("id = ?", in.UserId).Find(&data).Error; err != nil {
		panic(err)
	}

	return &goodsrpc.FenResponse{
		Title: data.Title,
		Post:  data.Post,
		Shu:   data.Shu,
		Pole:  data.Pole,
	}, nil
}
